Skip to content

Conversation

typotter
Copy link
Collaborator

@typotter typotter commented Nov 6, 2024

fixes FF-3485


labels: mergeable

Fixes: #FF-3485

Motivation and Context

The initial fetch logic of the client ignores polling configuration when the cache is unexpired.

Description

  • Polling checks the cache each time it runs, and then decide whether to do a network fetch
  • Polling interval is now a config param

How has this been tested?

Unit tests

throwOnFailedInitialization = false,
skipInitialPoll = false,
} = this.configurationRequestParameters;
if (pollingIntervalMs <= 0) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a reasonable guard/error-action to take here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can still log the error, and then perhaps set it to the default? Alternatively, we could use an invalid polling interval to mean don't poll, which would be consistent with other SDKs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting to default is the way to go. Since there are pollAfterSuccessfulInitialization and pollAfterFailedInitialization, it doesn't make sense for an invalid argument to implicitly override the variables explicitly controlling this behaviour.

},
);
const pollingCallback = async () => {
if (await this.flagConfigurationStore.isExpired()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polling = frequent checking of the cache and, if necessary, a fetch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@typotter typotter changed the title polling interval param, keep polling and check cache expiration in ca… fix: Polling after initial cached config Nov 6, 2024
Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for jumping on this!

expect(variation).toBe(pi);
});

describe('Poll after successful start', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

throwOnFailedInitialization = false,
skipInitialPoll = false,
} = this.configurationRequestParameters;
if (pollingIntervalMs <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can still log the error, and then perhaps set it to the default? Alternatively, we could use an invalid polling interval to mean don't poll, which would be consistent with other SDKs

},
);
const pollingCallback = async () => {
if (await this.flagConfigurationStore.isExpired()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@typotter typotter merged commit 94c6f67 into main Nov 6, 2024
2 checks passed
@typotter typotter deleted the tp/ff-3485 branch November 6, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants